* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    height: 100vh;
    background: linear-gradient(#99f, #f99);
}

body,
.navbar,
.navbar ul {
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar {
    position: relative;
    padding: 20px;
    background-color: #fff;
    border-radius: 50px;
}

.navbar input {
    width: 40px;
    height: 40px;
    opacity: 0;
    cursor: pointer;
}

/* 设置两条线 */
.navbar span {
    position: absolute;
    left: 25px;
    /* 现将两条线都放在一起，然后单独设置第二条线的位置，calc方法可以自动计算数值 */
    top: calc(50% - 10px);
    width: 30px;
    height: 4px;
    background-color: #999;
    border-radius: 15px;
    /*
    解决一个问题，现在 spann 覆盖着复选框，当鼠标放到 span 点不中复选框，通过以下属性便可解决这个问题，即使在 span
    上点击也能选中复选框
     */
    pointer-events: none;
    /* 收回来时过渡刚好相反 */
    transition: transform .3s ease-in-out, top .3s ease-in-out .3s;
}

.navbar span:nth-child(3) {
    top: calc(50% + 6px);
}

.navbar ul {
    width: 0;
    overflow: hidden;
    /* 现在何止是扁的，这是因为文字被换行显示了，两个汉字竖着排列了，就撑大盒子了 */
    white-space: nowrap;
    transition: all .5s;
}

.navbar ul li {
    list-style: none;
    margin: 0 15px;
}

.navbar ul li a {
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.navbar ul li a:hover {
    color: #fb7299;
}

.navbar input:checked ~ ul {
    width: 350px;
}

.navbar input:checked ~ span:nth-child(2) {
    top: calc(50% - 2px);
    transform: rotate(-45deg);
    background-color: #fb7299;
    /* 现在速度太快了，加个过渡 */
    transition: top .3s ease-in-out, transform .3s ease-in-out .3s;
}

.navbar input:checked ~ span:nth-child(3) {
    top: calc(50% - 2px);
    transform: rotate(45deg);
    background-color: #fb7299;
    /* 现在速度太快了，加个过渡 */
    transition: top .3s ease-in-out, transform .3s ease-in-out .3s;
}
